<template>
  <div ref='projectWrapper' style='height: 100%;position: relative'>
    <a-card :bordered='false' style='height: 100%'>
      <div class='table-page-search-wrapper'>
        <a-form layout='inline' @keyup.enter.native='searchQuery'>
          <a-row :gutter='24'>
            <a-col :xl='24' :lg='7' :md='8' :sm='24'>
              <a-radio-group v-model='queryParam.propertyStatus' @change='radioChange'>
                <a-form-item label='项目属性'>
                  <a-radio :value='0'>在建项目</a-radio>
                  <a-radio :value='1'>全部</a-radio>
                </a-form-item>
              </a-radio-group>
            </a-col>
          </a-row>
          <a-row :gutter='24'>
            <a-col :xl='6' :lg='7' :md='8' :sm='24'>
              <a-form-item label='项目编号'>
                <a-input placeholder='请输入项目编号' v-model='queryParam.code'></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl='6' :lg='7' :md='8' :sm='24'>
              <a-form-item label='项目简称'>
                <a-input placeholder='请输入项目简称' v-model='queryParam.shortName'></a-input>
              </a-form-item>
            </a-col>
            <template v-if='toggleSearchStatus'>
              <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
              <!--              <a-form-item label="项目属性">-->
              <!--                <j-dict-select-tag placeholder="请选择项目属性" v-model="queryParam.projectProperty"-->
              <!--                                   dictCode="project_property"/>-->
              <!--              </a-form-item>-->
              <!--            </a-col>-->
              <a-col :xl='6' :lg='7' :md='8' :sm='24'>
                <a-form-item label='项目分类'>
                  <j-dict-select-tag placeholder='请选择项目分类' v-model='queryParam.type'
                                     dictCode='icm_project_type' />
                </a-form-item>
              </a-col>
              <a-col :xl='6' :lg='7' :md='8' :sm='24'>
                <a-form-item label='是否延期'>
                  <j-dict-select-tag placeholder='请选择项目状态' v-model='queryParam.isDefer'
                                     dictCode='switch_status' />
                </a-form-item>
              </a-col>
              <a-col :xl='6' :lg='7' :md='8' :sm='24'>
                <a-form-item label='项目状态'>
                  <j-dict-select-tag placeholder='请选择项目状态' v-model='queryParam.projectState'
                                     dictCode='hf_project_states' />
                </a-form-item>
              </a-col>
              <a-col :xl='6' :lg='7' :md='8' :sm='24'>
                <a-form-item label='项目经理'>
                  <a-input placeholder='请输入项目经理' v-model='queryParam.charger'></a-input>
                </a-form-item>
              </a-col>
            </template>
            <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
              <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
              <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
              <a @click='handleToggleSearch' style='margin-left: 8px'>
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <div>
        <a-table
          ref='table'
          size='middle'
          :scroll='{x:true}'
          bordered
          :rowKey='(record,index)=>record.code+index'
          :columns='columns'
          :dataSource='dataSource'
          :pagination='ipagination'
          :loading='loading'
          class='j-table-force-nowrap'
          @change='handleTableChange'>
        </a-table>
      </div>
    </a-card>
    <hf-pm-project-check-modal ref='HfPmProjectCheckModal'></hf-pm-project-check-modal>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'
import HfPmProjectCheckModal from '@views/hifar/pm/modules/HfPmProjectCheckModal'
import { splitByNum } from '@/utils/util'

export default {
  name: 'HfPmProjectCheck',
  mixins: [JeecgListMixin],
  components: { HfPmProjectCheckModal },
  provide() {
    return {
      getContainer: () => this.$refs.projectWrapper
    }
  },
  data() {
    return {
      description: '中心核算管理页面',
      // 表头
      isorter: {
        column: 'code',
        order: 'desc'
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '项目编号',
          dataIndex: 'code',
          align: 'center',
          customRender: function(t, item, index) {
            return <a onClick={() => {
              this.handleDetail(item)
            }}>{t}</a>
          }.bind(this)
        },
        {
          title: '项目简称',
          dataIndex: 'shortName',
          align: 'center'
        },
        {
          title: '客户简称',
          dataIndex: 'customerName',
          align: 'center'
        },
        {
          title: '类型',
          dataIndex: 'type_dictText',
          align: 'center'
        },
        {
          title: '状态',
          dataIndex: 'projectState_dictText',
          align: 'center'
        },
        {
          title: '项目经理',
          dataIndex: 'charger',
          align: 'center'
        },
        {
          title: '项目金额',
          dataIndex: 'money',
          align: 'center',
          customRender: (t, item, index) => {
            return splitByNum(+t)
          }
        },
        {
          title: '回款金额',
          dataIndex: 'actualMoney',
          align: 'center',
          customRender: (t, item, index) => {
            return splitByNum(+t)
          }
        },
        {
          title: '预计成本',
          dataIndex: 'planContractCost',
          align: 'center',
          customRender: (t, item, index) => {
            return splitByNum(+t)
          }
        },
        {
          title: '预计利润',
          dataIndex: 'planProfit',
          align: 'center',
          customRender: (t, item, index) => {
            return splitByNum(+t)
          }
        },
        {
          title: '实际成本',
          dataIndex: 'actualContractCost',
          align: 'center',
          customRender: (t, item, index) => {
            return splitByNum(+t)
          }
        },
        {
          title: '实际利润',
          dataIndex: 'actualProfit',
          align: 'center',
          customRender: (t, item, index) => {
            return splitByNum(+t)
          }
        }
      ],
      url: {
        list: '/pm/hfPmProjectCheck/checkList'
      },
      queryModel: true,
      queryParam: {
        propertyStatus: 0
      }
    }
  },
  methods: {
    handleDetail(item) {
      this.$refs.HfPmProjectCheckModal.show(item)

    },
    searchReset() {
      this.queryParam = {}
      this.queryParam.propertyStatus = 0
      this.loadData(1)
    },
    radioChange() {
      this.loadData()
    }
  }
}
</script>

<style scoped>

</style>